<?php

class ManageVisitlogAction extends LtAction
{
	public function __construct()
	{
		parent::__construct();
		$this->responseType = 'tpl';
		$this->layout = 'bylayout';

		$this->data['headnavbar']['visitlog'] = '';
		$this->data['headnavbar']['hyperlink'] = '';
		$this->data['headnavbar']['customer'] = '';
		$this->data['headnavbar']['index'] = '';
	}

	public function execute()
	{
		$this->data['roleinfo'] = ManagerRole::getRoleInfFromCookie(C('LtUrl')->generate('manage','Visitlog'));
		$this->template = "Manage-Visitlog";

		$noticestr = $this->context->get('noticestr');
		if(!empty($noticestr))
		{
			$noticestr = "<div class='warning'>{$noticestr}</div>";
		}
		$this->data['noticestr'] = $noticestr;

		$this->data['title'] = 'manage index';
		$this->data['actionFilePath'] = __FILE__;

		$page = $this->context->get('page');
		$page = max(intval($page), 1);

		$page_size = LtObjectUtil::singleton('LtConfig')->get('page_size');
		if (empty($page_size))
		{
			$page_size = 25;
		}
		$limit = $page_size;
		$offset = ($page-1) * $page_size;	

		$tmpdao = new VisitlogDao();
		
		$queryre = $tmpdao->getList('', null, 'itime desc', $offset, $limit);
		$this->data['queryre'] = $queryre;
		
		$pagination = new LtPagination;
		$pagination->init();

		$count = $tmpdao->getCount();
		$base_url = C('LtUrl')->generate('manage', 'Visitlog', array('page' => ':page'));
		$this->data['pagination'] = $pagination->pager($page, $count, $base_url);
	
		$this->data['headnavbar']['visitlog'] = 'selected';
	}
}
